<?php
require $this->__RAD__ . 'include/head.php';
?>
<body>
<?php require $this->__RAD__ . 'include/header.php';?>
<?php require $this->__RAD__ . 'include/banner.php';?>
<div class="contact feedback">
    <div class="wrapper">
        <h2>填写您的留言信息</h2>
        <p>
            我们将尽快给与您反馈 <span>（注：带<font color="#fe0000"> * </font>符号的内容为必填选项）</span>
        </p>
        <div class="form clearfix">
            <form>
                <div class="input">
                    <em>*</em>
                    <input type="text" id="name" style="background:url(<?= $this->__STATIC__?>images/icon06.png) no-repeat left 20px center;" placeholder="您的姓名">
                </div>
                <div class="input">
                    <input type="text" id="phone" style="background:url(<?= $this->__STATIC__?>images/icon07.png) no-repeat left 20px center;" placeholder="您的手机/电话">
                </div>
                <div class="input">
                    <em>*</em>
                    <input type="text" id="email" style="background:url(<?= $this->__STATIC__?>images/icon08.png) no-repeat left 20px center;" placeholder="您的邮箱">
                </div>
                <div class="input">
                    <em>*</em>
                    <input type="text" id="company" style="background:url(<?= $this->__STATIC__?>images/icon13.png) no-repeat left 20px center;" placeholder="公司">
                </div>
                <div class="input">
                    <input type="text" id="position" style="background:url(<?= $this->__STATIC__?>images/icon14.png) no-repeat left 20px center;" placeholder="部门/职位">
                </div>
                <div class="input">
                    <select id="subject" style="background:url(<?= $this->__STATIC__?>images/icon0010.png) no-repeat left 20px center,url(<?= $this->__STATIC__?>images/xl.png) no-repeat right 20px center;">
                        <option>请选择主题</option>
                        <option>服务支持</option>
                        <option>制剂产品</option>
                        <option>原料药产品</option>
                        <option>应聘</option>
                        <option>其它</option>
                    </select>
                </div>
                <div class="input wid100">
                    <em>*</em>
                    <textarea style="background:url(<?= $this->__STATIC__?>images/icon09.png) no-repeat left 20px top 15px;" id="content" placeholder="留言内容"></textarea>
                </div>
                <div class="input wid100">
                    <input type="hidden" value="<?= $this->contactHash?>" id="hash">
                    <input class="submit" id="subBtn" type="button" value="提交留言">
                </div>
            </form>
        </div>

    </div>
</div>
<?php require $this->__RAD__ . 'include/footer.php';?>
</body>
</html>
<script type="text/javascript" src="<?= $this->__STATIC__?>js/common.js"></script>
<script>
    $(function () {
        $('#subBtn').click(function () {
            var name = trim($('#name').val());
            var content = trim($('#content').val());
            var phone = trim($('#phone').val());
            var email = trim($('#email').val());
            var company = trim($('#company').val());
            var position = trim($('#position').val());
            var subject = trim($('select option:selected').text());
//            console.log(subject);return false;
            //验证电话邮箱
            var isMobile = /^1[3|4|5|7|8][0-9]\d{4,8}$/;
            var isPhone = /^(?:(?:0\d{2,3})-)?(?:\d{7,8})(-(?:\d{3,}))?$/;
            var isEmail = /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/;
            if ((content) == '') {
                alert('请填写内容!');
                $('#content').focus();
                return false;
            } else if (name == '' && name.length > 20) {
                alert('请填写正确的姓名!');
                $('#name').focus();
                return false;
            } else if (!isEmail.test(email)) {
                alert('请填写正确的邮箱!');
                $('#email').focus();
                return false;
            } else if ((company) == '') {
                alert('请填写正确的公司!');
                $('#email').focus();
                return false;
            } else {
                $.post('/api/form', {hash: $('#hash').val(), content : content, name : name, email : email, phone : phone, company: company, position: position, subject: subject},
                    function (data) {
                        switch (data.errcode) {
                            case 0:
                                alert('留言已成功提交!');
                                break;
                            default :
                                alert(data.errmsg);
                        }
                    },
                    'json');
            }

        });
        function trim(s){
            return s.replace(/(^\s*)|(\s*$)/g, "");
        }
    })
</script>